II Something
by Clark Hugh Stiles
December 19, 2001 

Last time we started up the 80 column card using a technique from July 1986's Open-Apple. Since that's how the finished program will begin, we may as well build the "look" this time, and work on the keyboard input routines in the next few issues. Note that you must type a space at the beginning of each line where there's a ! prompt followed by a three character command. 

Here's the probable final version of the initialization routine for the finished block editor program. It checks for the 80 column hardware and if not found, exits. If it is found, it starts up 80 columns (even if it is already started), then clears the disk block buffer space at $2000.21FF, sets VTAB and screen width, and prints the two memory pages as hex with no space between each byte. 

Prompts below are ], *, and ! indicating BASIC, Monitor, and Miniassembler, respectively. The space isn't showing up on the WWW postings. 

Listing 1: 
]CALL-151
*!
!1000:LDA BF98
! ROR
! ROR
! BCC 1047
! LDA #00
! STA BE30
! LDA #C3
! STA BE31
! LDA #99
! JSR FDED
! LDA #00
! TAX
! STA 2000,X
! INX
! BNE 1019
! STA 2100,X
! INX
! BNE 101F
! CLC
! LDA #40
! STA 21
! LDA #05
! STA 25
! JSR FC22
! LDX #00
! LDA 2000,X
! JSR FDDA
! INX
! BNE 1033
! LDA 2100,X
! JSR FDDA
! INX
! BNE 103C
! BCS 1048
! RTS
! JSR FDDA
! RTS

*BSAVE ZAP1A,A$1000,L$4C
*1000.104F
1000:AD 98 BF 6A 6A 90 40 A9 00 8D 30 BE A9 C3 8D 31--.?jj.@)..0>)C.1
1010:BE A9 99 20 ED FD A9 00 AA 9D 00 20 E8 D0 FA 9D->). m}).*.. hPz.
1020:00 21 E8 D0 FA 18 A9 40 85 21 A9 05 85 25 20 22-.!hPz.)@.!)..% "
1030:FC A2 00 BD 00 20 20 DA FD E8 D0 F7 BD 00 21 20-|".=. Z}hPw=.!
1040:DA FD E8 D0 F7 B0 01 60 20 DA FD 60 00 00 00 00-Z}hPw0.` Z}`....
*[control-c,return] 
End of Program Listing. 

An error trapping routine suggested in Open-Apple after the call to the 80 column hardware caused the program to weirdly bomb, and I couldn't see the problem, or foresee any problems without it, so I ditched it. 

We'll have to be careful so that when the memory pages need to be displayed or cleared and displayed, there will be no bad consequences when the program flows back down into the main loop (soon to be located at $1048 or thereafter). To finish up the screen display will require some text (the unit number and block number, maybe a title line, and a mnemonic for the available commands). I also want to make the program save the cursor location in the edit window because it's annoying to have it move around every time I do some other function. 
How It Works 
When you run this listing by typing 1000G at the * prompt, or CALL 4096 at the ] prompt, the 80 column card is activated if found. If not found, the program exits via BCC 1047 which points to RTS. The screen is blanked, and the memory locations from $2000 to $21FF are cleared to zero, then printed at VTAB 5. It may look like junk because the printing is in hexadecimal without any spaces. That's the way the entire 512 bytes of a disk block can appear on one screen. The LDA #$40, STA 21 sets the screen width to 64, in the same way that POKE 33,64 would do. STA 21 refers to the same memory location. 

This is another mostly relocatable routine. In the Beagle Bros "ProByter" disk zap program (a 40 column masterpiece) there were two ASCII modes, a hex mode, and a Catalog mode which made it easy to fiddle with the various entries, including the mod and creation dates. This program (probably) won't have the latter mode, but will have an ASCII mode and a hex mode. Don't worry, it will all make sense when you see it. 

II Infinitum! 